﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Abp.Application.Services.Dto;
using Abp.Web.Mvc.Authorization;
using MyCompanyName.AbpZeroTemplate.Authorization;
using MyCompanyName.AbpZeroTemplate.BrandApp;
using MyCompanyName.AbpZeroTemplate.BrandApp.Dto;
using MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Models.Brand;
using MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Models.Category;

namespace MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Controllers
{
    [AbpMvcAuthorize(AppPermissions.Pages_Brand)]
    public class BrandController : Controller
    {
        private IBrandAppService _brandAppService;
        public BrandController(IBrandAppService brandAppService)
        {
            _brandAppService = brandAppService;
        }
        // GET: Mpa/Brand
        public ActionResult Index()
        {
            return View();
        }

        [AbpMvcAuthorize(AppPermissions.Pages_Brand_Create)]
        public ActionResult CreateModal()
        {
            return PartialView("_CreateModal");
        }

        [AbpMvcAuthorize(AppPermissions.Pages_Brand_Edit)]
        public ActionResult EditModal(Guid id)
        {
            BrandOutput brand = _brandAppService.GetBrandForEdit(new EntityRequestInput<Guid>(id));
            BrandViewModel brandViewModel = new BrandViewModel()
            {
                Id = brand.Id,
                Name = brand.Name,
                Description = brand.Description
            };
            return PartialView("_EditModal", brandViewModel);
        }
    }
}